class Node():
    def __init__(self,nodename,hostname:str="local",host_ip:str='localhost',port:int=8000):
        self.hostname = hostname
        self.nodename = nodename
        self.host_ip = host_ip
        self.port = port

    def __str__(self):
        return f"nodename:{self.nodename}\thost:{self.hostname}\tlisten_ip:{self.host_ip}"

    # def dump_as_dict(self):
    #     raise Exception('未完成,打算转化成dict')


class NodeKeeper():
    def __init__(self):
        self.dict = {}

    def add_node(self,node:Node):
        # 这里应该有错误处理.
        self.dict[node.nodename] = node

    def pop_node(self,nodename):
        del self.dict[nodename]
        pass

    def all_node(self):
        return self.dict

    def all_name_only(self):
        return [name for name in self.dict]

# class NodeKeeper_Memery(NodeKeeper):
#     def __init__(self):
#         self.dict = {}